package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.AfterLoansService;
import com.woniu.p2p.entity.Invest;
import com.woniu.p2p.entity.InvestAfterloan;
import com.woniu.p2p.mapper.InvestAfterloanMapper;
import com.woniu.p2p.mapper.InvestMapper;
import com.woniu.p2p.vo.InvestAndAfterLoansVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AfterLoansServiceImpl implements AfterLoansService {

    @Autowired
    InvestAfterloanMapper investAfterloanMapper;
    @Autowired
    InvestMapper investMapper;



    @Override
    public PageInfo<InvestAndAfterLoansVo> findAllAfterLoans(Integer start, Integer num, String afterloanstatus, Date predate, Date nextdate, String afterloankeyword) {
        PageHelper.startPage(start,num);
        List<InvestAndAfterLoansVo> list = investAfterloanMapper.findAllAfterLoans(afterloanstatus, predate, nextdate, afterloankeyword);
        PageInfo<InvestAndAfterLoansVo> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Invest findAllInvestById(Integer id) {
        return investMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteInvestAfterloans(Integer id) {
        return investAfterloanMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Invest> findAllInvestByAfterloansId(Integer id) {
        return investMapper.findAllInvestByAfterloansId(id);
    }

    @Override
    public List<Invest> findAllInvest() {
        return investMapper.selectAll();
    }

    @Override
    public int insertAfterloans(InvestAfterloan investAfterloan) {
        return investAfterloanMapper.insert(investAfterloan);
    }

    @Override
    public int findNewInsertShuJu() {
        return investAfterloanMapper.findNewInsertShuJu();
    }

    @Override
    public int updateInvestAfterloansId(Integer id,Integer afterId) {
        return investMapper.updateAfterloansId(id,afterId);
    }

    @Override
    public List<InvestAndAfterLoansVo> findAllAfterloans(int[] id) {
        return investAfterloanMapper.findAllAfterLoansByIdes(id);
    }

    @Override
    public List<InvestAfterloan> selectAll() {
        return investAfterloanMapper.selectAll();
    }
}
